<?php
//echo '<pre>';
$user_list = $this->users;
$search_val = $this->search_val;
?>

<div class="box span12">
<div class="box-header well" data-original-title="">
    <h2><i class="icon-user"></i> Members </h2>

    <a class="btn btn-primary pull-right" style="" href="<?php echo $this->url('admin/child', array('controller'=>'user','action'=>'add')) ?>">
        <i class="icon-edit icon-white"></i>
        New User
    </a>
</div>
<div class="box-content">
<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
    <!--start search  -->
    <div class="row-fluid">
        <div class="span6">

        </div>
        <div class="span4 pull-right">
            <div class="dataTables_filter" id="DataTables_Table_0_filter">
                <!--search form -->
                <form action="<?php echo $this->url('admin/child',array('controller'=>'user')) ?>" method="get">
                    <label>Search:
                        <input type="text" value="<?php if(isset($search_val)) echo $search_val ?>" name="search_val" aria-controls="DataTables_Table_0">
                        <input type="submit" class="btn btn-primary pull-right" value="Search" />
                    </label>
                </form>
                <!--end search form -->
            </div>
        </div>
    </div>

    <!--end search  -->
<table class="table table-striped table-bordered bootstrap-datatable datatable dataTable" id="DataTables_Table_0"
       aria-describedby="DataTables_Table_0_info">
<thead>
<tr role="row">
    <th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
        aria-sort="ascending" aria-label="Username: activate to sort column descending" style="width: 201px;">Username
    </th>
    <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
        aria-label="Date registered: activate to sort column ascending" style="width: 199px;">Email
    </th>
    <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
        aria-label="Role: activate to sort column ascending" style="width: 96px;">Phone
    </th>
    <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
        aria-label="Status: activate to sort column ascending" style="width: 103px;">Address
    </th>
    <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
        aria-label="Actions: activate to sort column ascending" style="">Status
    </th>
    <th class="sorting center" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
        aria-label="Actions: activate to sort column ascending" style="width: 378px;">Actions
    </th>
</tr>
</thead>

<tbody role="alert" aria-live="polite" aria-relevant="all">
    <?php
    $i=1;
    foreach($user_list as $user){
        $class = "odd";
            if($i%2==0)
                $class="event";
        ?>
    <tr class="<?php echo $class; ?>">
        <td class=" sorting_1"><?php echo \Velacolib\Utility\Utility::str_highlight($user->name,$search_val) ?></td>
        <td class="center "><?php echo \Velacolib\Utility\Utility::str_highlight($user->email ,$search_val) ?></td>
        <td class="center "><?php echo \Velacolib\Utility\Utility::str_highlight( $user->phone ,$search_val) ?></td>
        <td class="center ">
            <?php echo \Velacolib\Utility\Utility::str_highlight( $user->address ,$search_val) ?>

        </td>
        <td class="center ">
            <?php echo $user->status ?>
        </td>
        <td class="center ">
            <a class="btn btn-success" href="<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'detail','id'=>$user->id)) ?>">
                <i class="icon-zoom-in icon-white"></i>
                View
            </a>
            <a class="btn btn-info" href="<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'edit','id'=>$user->id)) ?>">
                <i class="icon-edit icon-white"></i>
                Edit
            </a>
            <a class="btn btn-danger" href="<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'delete','id'=>$user->id)) ?>">
                <i class="icon-trash icon-white"></i>
                Delete
            </a>
        </td>
    </tr>
   <?php
    }
    $i++;
   ?>
</tbody>
</table>
    <!--paginator -->
<div class="row-fluid">
    <?php // add at the end of the file after the table
    echo $this->paginationControl(
    // the paginator object
        $user_list,
        // the scrolling style; see http://zf2.readthedocs.org/en/release-2.1.4/modules/zend.paginator.usage.html#rendering-pages-with-view-scripts
        'sliding',
        // the partial to use to render the control
        array('partial/paginator.phtml', 'User'),
        // the route to link to when a user clicks a control link
        array(
            'route' => 'admin/child',
            'child_route' => array('controller'=>'user')
        )
    );
    ?>
</div>
    <!--end paginator -->

</div>
</div>